//
//  BKUserRecordNumTableView.m
//  bestkeep
//
//  Created by windCould on 16/11/16.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKUserRecordNumTableView.h"
#import "BKMyCommon.h"
#import "BKUserNumRecordViewCell.h"
@interface BKUserRecordNumTableView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView * ListTaebleView;
@property (nonatomic,strong)UIView * headerView;


@end



@implementation BKUserRecordNumTableView


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = ThemeBackgroundColor;
        [self setUpViews];
        
    }
    
    return  self;
}

-(void)setUpViews{
    
    _headerView = [[UIView alloc]initWithFrame:CGRectZero];
    _headerView.backgroundColor = HexColor(0xdddddd);
    [self  addSubview:_headerView];
    
    _ListTaebleView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    _ListTaebleView.dataSource = self;
    _ListTaebleView.delegate= self;
    _ListTaebleView.tableFooterView = [[UIView alloc]init];
    _ListTaebleView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self addSubview:_ListTaebleView];
    [self layoutViews];
}


-(void)layoutViews{
    
    
     _headerView.frame = CGRectMake(55, 0, SCREENWIDTH-55, 0.5);
    [_ListTaebleView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_headerView.mas_bottom).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
    }];
    
   
    
}

-(void)setDataArray:(NSArray *)dataArray
{
    _dataArray = dataArray;
    [_ListTaebleView reloadData];
}

#pragma mark ============= mainTableViewDelegate =======================

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 50;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 50;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    BKUserNumRecordViewCell * cell = [BKUserNumRecordViewCell cellWithTaleview:tableView];
   // cell.textLabel.text = _dataArray[indexPath.row];
    cell.titleStr = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.recordDelegate respondsToSelector:@selector(bkUserRecordNumTableView:userSelectRecordNum:)]) {
        
        [self.recordDelegate bkUserRecordNumTableView:self userSelectRecordNum:_dataArray[indexPath.row]];
    }
    
    
}


@end
